/*global bd, gadgets */ define(function (require, exports, module) { 'use strict'; var $ = require('jquery'); // mock lp objects // var lpPortal = { designMode: bd.designMode === 'true' }; var lpCoreUtils = { parseBoolean: function (val) { return (typeof val === 'boolean' && val) || (typeof val === 'string' && /\s*true\s*/i.test(val)) || (typeof val === 'number' && val !== 0); } }; var lpCoreBus = gadgets.pubsub; //maps pubsub events to widget behavior tags // [pubsub event] : [widget's behavior tag] var showWidgetByEventMap = { //For Travel RD // 'launchpad-TravelRD.travelRecurringDeposit':'idfc-create-travel-rd', 'launchpad-TravelRD.no-TravelRd-apply-now':'idfc-no-TravelRD-apply-now', 'launchpad-retail.viewAccounts': 'accounts', 'launchpad-retail.accountSelected': 'transactions', 'launchpad-retail.portfolioSelected': 'wealth', 'launchpad-retail.requestMoneyTransfer': 'new-transfer', 'launchpad-retail.requestMoneyTransferSoleprop': 'bbsp-new-transfer', 'launchpad-retail.transactions.applyFilter': 'transactions', 'launchpad-retail.paymentOrderInitiated': 'review-transfers', 'launchpad-retail.paymentOrderInitiatedSoleprop': 'idfcbbsp-review-transfers', 'launchpad-retail.openP2PPreferences': 'p2p-preferences', 'launchpad-retail.openP2PEnrollment': 'p2p-enrollment', 'launchpad-retail.openP2PTransactions': 'p2p-transactions', 'launchpad-retail.openCardManagement': 'card-management', 'launchpad-retail.viewProfile': 'profile', 'launchpad-retail.openEBillDashboard': 'billpay-dashboard', 'launchpad-retail.openDeposits' : 'open-deposits', 'launchpad-retail.depositDetails' : 'idfc-view-deposit', 'launchpad-retail.ProfileContact' :'profile-contact', 'launchpad-retail.depositsClosure' : 'deposits-closure', 'launchpad-retail.profileContactWidgetOpen' : 'view-profile', 'contactsWidget' : 'address-book', 'launchpad-retail.reviewTransfersApp':'review-transfers-transfers', 'TrackServiceRequest':'track-service-request', 'MyApp':'service-request', 'launchpad-retail.forgotAPIN': 'forgot-apin', 'launchpad-retail.viewSettings': 'view-settings', 'launchpad-retail.forgotPassword': 'ForgetPassword', 'launchpad-retail.account-unlock': 'account-unlock', 'launchpad.challenge.questions' : 'challenge-questions', 'launchpad.challenge.questions.postLogin' : 'challenge-questions', 'launchpad-retail.forgotLoginId': 'forgot-id', 'launchpad-retail.requestNewTransfer':'new-transfer', 'launchpad-retail.refreshAccountSummary':'idfcaccounts', 'launchpad-retail.serviceRequestOpen':'service-request', 'launchpad-retail.serviceRequestOpenRd' : 'service-request', 'launchpad-retail.goBackReviewTransfer':'review-transfers-transfers', 'launchpad-retail.summary' : 'profile-summary', 'launchpad-retail.openLoanSummary' : 'idfc-loan-summary', 'launchpad-billPay.add-biller':'add-biller', 'launchpad-billPay.transaction-history':'transaction-history', 'launchpad-billPay.manage-biller':'manage-biller', 'launchpad-retail.loanCertificate' : 'loan-Certificate', 'launchpad-retail.grouping.serviceRequest':'service-request', 'launchpad-retail.grouping.debitcard':'group-dcms', 'launchpad-retail.cardSummary': 'cardSummary', 'launchpad-retail.blockCard': 'blockCard', 'launchpad-retail.issueDebitCard': 'issueDebitCard', 'launchpad-retail.no-nri-rd': 'no-nri-rd', 'launchpad-retail.dcmsLimitManagement': 'cardLimit', 'launchpad-retail.limitFungibility': 'idfc-limit-fungibility', 'launchpad-retail.openRecurringDeposits' : 'createRecurringDeposits', 'launchpad-retail.recurringDepositDetails' : 'recurringDetails', 'launchpad-retail.recurringDepositsClosure' : 'recurringClosure', 'launchpad-retail.openLoanStmtAcc' : 'loan-statementofaccount', 'launchpad-retail.openRepaymentSchd' : 'loan-repayment', 'launchpad-retail.openLoanSimulator' : 'loan-simulator', 'launchpad-billPay.idfc-view-bills' : 'idfc-view-bills', 'launchpad-billPay.idfc-quick-pay' : 'idfc-quick-pay', 'launchpad-billPay.recharge' : 'recharge', 'launchpad-retail.limit-management':'limit-management', 'launchpad-retail.soleprop-limit-management':'idfc-soleprop-limit-management', 'launchpad.create-era' : 'idfc-create-era', 'launchpad-retail.stop-cheque' : 'idfc-stop-cheque', // BIB CHanges Start 'launchpad-business.stop-cheque' : 'idfcbb-stop-cheque', 'launchpad-retail.dashboard':'dashboard', 'launchpad-business.dashboard-settings':'idfcbb-dashboard-settings', 'launchpad-business.toa-link':'idfcbb-toa-link', 'launchpad-business.toa-delink':'idfcbb-toa-delink', 'launchpad-business.toa-sweeps':'idfcbb-toa-sweeps', 'launchpad-business.toa-apply':'idfcbb-toa-apply', 'launchpad-business.toa-udc':'idfcbb-toa-udc', 'launchpad-retail.sweepMandate': 'sweepMandate', 'launchpad-business.portfolioChange':'account-summary', 'launchpad-business.transactionApproval': 'idfcbb-transaction-approval', 'launchpad-business.depositsClosure' : 'idfcbb-deposits-closure', 'launchpad-business.accountSelected': 'idfcbb-transaction', 'launchpad-business.refreshAccountSummary':'idfcbb-account', 'launchpad-business.openDeposits' : 'idfcbb-open-deposits', 'launchpad-business.requestMoneyTransfer': 'idfcbb-new-transfer', 'launchpad-business.reviewTransfersApp':'idfcbb-review-future-transfers', 'launchpad-business.paymentOrderInitiated': 'idfcbb-review-transfers', 'launchpad-business.requestNewTransfer':'idfcbb-new-transfer', 'launchpad-business.serviceRequestOpen':'idfcbb-service-request', 'launchpad-business.serviceRequestOpenRd' : 'idfcbb-service-request', 'launchpad-retail.modifyNomineeOpen' : 'modify-nominee', 'launchpad-business.depositDetails' : 'idfcbb-view-deposit', 'launchpad-retail.delNomineeOpen' : 'del-nominee', 'launchpad-business.contactsWidget' : 'idfcbb-addressbook', 'launchpad-business.openRepaymentSchd' : 'idfcbb-loan-repayment-schedule', 'launchpad-business.openLoanStmtAcc' : 'idfcbb-loan-soa', 'launchpad-business.serviceRequest':'idfcbb-service-request', 'launchpad-business.trackRequest':'idfcbb-track-service-request', 'launchpad-business.groupTransactions':'idfcbb-group-transactions', 'launchpad-business.limitsDaily':'idfcbb-group-limits', 'launchpad-business.idfcAdminLimitMangement':'idfc-admin-limit-management', 'launchpad-business.idfcSolpropLimitMangement':'idfc-soleprop-limit-management', 'launchpad-business.TransactionSummary':'idfcbb-transaction-summary', 'launchpad-business.RaiseAnIssue':'idfcbb-register-complaint', 'launchpad-business.InterestLetter':'idfcbb-interest-letter', 'launchpad-business.TradeForms':'trade-documents-forms', 'launchpad-business.viewProfileWidgetOpen' : 'idfcbb-view-profile', 'launchpad-business.myToa':'idfcbb-toa', 'launchpad-business.changePassword' : 'idfcbbe-admin-user-change-password', 'launchpad-business-sp.ServiceRequest':'idfcbbsp-service-request', 'srValidationCheckpublish':'loan-apply-now', // BIB CHanges End //Ecommerce Changes 'launchpad-userMaintenance.operation':'userresetoperation', 'launchpad-userMaintenance.reset':'userresetmerchant', 'launchpad-userMaintenance.resetUserRecon':'userresetrecon', 'launchpad-userMaintenance.createMer':'createmerchantuser-widget', 'launchpad-userMaintenance.ceateOpt':'createoperationuser-widget', 'launchpad-userMaintenance.ceateRecon':'ceateReconWidget', 'launchpad-userMaintenance.deactivateMer':'deactivateuser-widget', 'launchpad-userMaintenance.deactivateOpt':'deactivateoperation-widget', 'launchpad-userMaintenance.deactivateRecon':'deactivateRecon', 'launchpad-merchantMaintenance.createMaker':'createMaker', 'launchpad-merchantMaintenance.createChecker':'createChecker', 'launchpad-merchantMaintenance.modifyMaker':'modifyMaker', 'launchpad-merchantMaintenance.modifyChecker':'modifyChecker', 'launchpad-merchantMaintenance.deleteMaker':'deleteMaker', 'launchpad-merchantMaintenance.deleteChecker':'deleteChecker', 'launchpad-merchantMaintenance.activateMaker':'makerActivate', 'launchpad-merchantMaintenance.activateChecker':'activateChecker', 'launchpad-merchantMaintenance.deactivateMaker':'deactivateMaker', 'launchpad-merchantMaintenance.deactivateChecker':'deactivateChecker', 'launchpad-retail.makerDeactivate' : 'makerdeact', 'launchpad-retail.makerActivate' : 'makeract', 'launchpad-retail.makerDelete' : 'makerdel', 'launchpad-retail.checkerDeactivate' : 'checkerdeact', 'launchpad-retail.checkerActivate' : 'checkeract', 'launchpad-retail.checkerDelete' : 'checkerdel', 'launchpad-change-password':'change-password', 'launchpad-retail.insuranceSummary':'idfc-insurance-summary', 'launchpad-retail.lifeInsurance':'idfc-life-insurance', 'launchpad-retail.healthInsurance':'idfc-health-insurance', 'launchpad-retail.motorInsurance':'idfc-motor-insurance', 'launchpad-retail.travelInsurance':'idfc-travel-insurance', 'launchpad-retail.ulipInsurance':'idfc-ulip-insurance', 'launchpad-goldBond.investments':'idfc-gold-investments', 'launchpad-goldBond-history':'idfc-gold-bond-history', 'launchpad-goldBond-checker':'idfc-gold-bond-checker', 'launchpad-goldBond-maker': 'idfc-gold-bond-maker', 'launchpad-retail.openPersonalLoanSummary' : 'idfc-personal-loan-summary', 'launchpad-retail.openPersonalLoanRepaymentSchedule' : 'personal-loan-repayment', 'launchpad-retail.openPersonalLoanSOA' : 'personal-loan-statementofaccount', 'launchpad-retail.openPersonalLoanDetail' : 'personal-loan-Detail', 'launchpad-retail.openLAPSummary' : 'idfc-lap-summary', 'launchpad-retail.openLAPDetail' : 'lap-Detail', 'launchpad-retail.openLAPRepaymentSchedule' : 'lap-repayment', 'launchpad-retail.openLAPSOA' : 'lap-statementofaccount', 'launchpad-retail.openApplyNow' : 'apply-now', 'launchpad-retail.openLoanApplyNow' : 'loan-apply-now', 'launchpad-retail.no-loan-apply-now' : 'no-loan-apply-now', 'launchpad-retail.groupLoans' : 'group-Loans', 'launchpad-retail.groupTfundsTransfer':'group-funds-transfer', 'launchpad-retail.groupDcms':'group-dcms', 'launchpad-retail.groupRecurringDeposits':'group-RecurringDeposits', 'launchpad-retail.limitManagement':'limit-management', 'launchpad-retail.groupDeposits':'group-deposits', 'launchpad-business.bulkFileUpload' : 'idfcbb-bulk-file-upload', 'launchpad-business.bulkFileStatusInqiry' : 'idfcbb-file-status-inquiry', /* 'launchpad-retail.openCommercialVehicleLoanSOA' : 'idfc-commercial-vehicle-loan-summary', 'launchpad-retail.openCommercialVehicleLoanRepaymentSchedule' : 'idfc-cv-repayment-schedule', 'launchpad-retail.openCommercialVehicleLoanSummary' : 'idfc-commercial-vehicle-loan-summary', */ // BIB CHanges End //MVP changes Start 'launchpad-business.pastApprovals': 'idfcbb-past-approvals', 'launchpad-business.initByMe': 'idfcbb-initiated-by-me', 'launchpad-business.rejByMe': 'idfcbb-rejected-by-me', 'launchpad-business.addNominee': 'idfcbb-add-nominee', 'launchpad-business-soleprop.addNominee': 'idfcbbsp-add-nominee', 'launchpad-business.changeEmail': 'idfcbb-change-email', 'launchpad-business-soleprop.trackSR': 'idfcbbsp-track-service-request-widget', //Added for IFSC search 'launchpad.ifscSearch' : 'idfc-ifsc-search', //bb loans 'launchpad-retail.openBusinessLoanSummary' : 'idfc-business-loan-summary', 'launchpad-retail.openBusinessLoanRepaymentSchedule' : 'business-loan-repayment', 'launchpad-retail.openBusinessLoanSOA' : 'business-loan-statementofaccount', 'launchpad-retail.openBusinessLoanDetail' : 'business-loan-Detail', 'launchpad-retail.BusinessloanCertificate' : 'business-loan-Certificate', //MVP changes End //Business Bill Pay Start 'launchpad-bib-billPay.add-biller':'idfcbb-add-biller', 'launchpad-bib-billPay.transaction-history':'idfcbb-transaction-history', 'launchpad-bib-billPay.manage-biller':'idfcbb-manage-biller', 'launchpad-bib-billPay.view-bills':'idfcbb-view-bills', 'launchpad-bib-billPay.quick-pay':'idfcbb-quick-pay', 'launchpad-bib-billPay.recharge':'idfcbb-recharge', //Business Bill Pay End // ASBA 'launchpad-retail.idfc-asba-apply' : 'idfc-asba-apply', 'launchpad-retail.idfc-asba-orderBook' : 'idfc-asba-orderBook', // WMS MF Start 'launchpad-wms.MFReports':'idfc-mf-report', 'launchpad-wms.Investments':'idfc-group-investments', 'launchpad-wms.insurance':'idfc-group-insurance', 'launchpad-wms.MFSummary':'idfc-mf-summary', 'launchpad-wms.MFBuy':'idfc-mf-buy', 'launchpad-wms.NRMfBuy':'idfc-mf-nr-buy', 'launchpad-wms.NRMfSummary':'idfc-nr-mf-summary', 'launchpad-wms.MFRedeem':'idfc-mf-redeem', 'launchpad-wms.MFRedeemTransHistory':'idfc-mf-transaction-history', 'launchpad-wms.MFSwitch':'idfc-mf-switch', 'launchpad-wms.MFMyOrders':'idfc-mf-my-orders', 'launchpad-wms.MFMyOrdersDetails':'idfc-mf-order-details', 'launchpad-wms.MutualFund':'idfc-mf-tnc', 'launchpad-wms.Fatca':'idfc-mf-fatca', 'launchpad-wms.MFMyRP':'idfc-mf-risk-profiler', 'launchpad-tax.efilling':'idfc-tax-efilling', 'launchpad-pay.taxes':'idfc-pay-taxes', 'launchpad-group.efilling':'idfc-group-tax-filling', 'launchpad-bbgroup.efilling':'idfcbb-group-tax-filling', // WMS MF End // LAP entity start 'launchpad-bib-LAPSummary.openLAPSummary':'idfcbb-lap-summary', 'launchpad-bib-LAPSOA.openLAPSOA':'idfcbb-lap-soa', 'launchpad-bib_LAPRepaymentSchedule.openLAPRepaymentSchedule':'idfcbb-lap-repayment-schedule', // LAP entity end //Block Unblock Changes Start 'launchpad-retail.generateChangeAPin' : 'generate-change-card-pin', 'launchpad-retail.block-unblock-user' : 'block-unblock-user', 'launchpad-retail.idfc-forgot-ucic':'idfc-forgot-ucic', //Block Unblock Changes End // for FD RD sole prop testing 'launchpad-retail.idfc-view-deposit-summary':'idfc-view-deposit-summary', /*Added by Apptech on 07/12/2017 for the inclusion of Loan Part Prepayment / Foreclosure links*/ 'launchpad-retail.openPLPartPrepaymentForeclosure':'pl-partprepayment-foreclosure', 'launchpad-retail.idfc-payments':'idfc-payments', /*End of changes*/ /*UAM*/ 'launchpad-admin.forcePassword' : 'admin-force-password', 'launchpad-admin.openPendingApprovals' : 'idfc-admin-transaction-approval', /*GSTIN Starts*/ 'launchpad-retail.gstinWidgetOpen':'idfc-gstin-update', /*GSTIN Ends*/ 'launchpad-business.schedulePickups':'idfcbb-dsb-schedule', 'launchpad-business.my-pickups':'idfcbb-dsb-my-pickups', 'launchpad-retail.overdraftFD' : 'idfc-overdraft-fd', /*Deposit slip*/ 'launchpad-retail.depositSlip' : 'idfc-deposit-slip', 'launchpad-retail.tdsInterestCertificate' : 'idfc-tds-cert', /* cancer care */ 'launchpad-retail.cancerInsurance' : 'idfc-cancer-insurance', 'launchpad-retail.idfc-nri-open-account': 'idfc-nri-open-account', 'launchpad-retail.togglePrimaryAccount': 'idfc-toggle-primary-account', 'launchpad-retail.linkUnlinkSecAccount': 'idfc-link-unlink-secondary-account', /* home insurance */ 'launchpad-retail.homeInsurance' : 'idfc-home-insurance', 'launchpad-retail.debitCardSummary': 'idfc-debit-card-summary', /* PLSTP Starts */ 'launchpad-retail.idfc-plstp': "idfc-avail-personal-loan", /* bill pay*/ 'launchpad-retail.bill-payment':'idfc-bill-payment', 'launchpad-retail.bill-payment-aus' : 'idfcbb-bill-payment', 'launchpad-retail.group-bill-pay': 'group-bill-pay', /* panel links */ 'launchpad-retail.openTermLoan':'idfc-term-loan', 'launchpad-retail.pin-generate': 'pin-generate', 'launchpad-retail.newUserRegistration': 'new-user', 'launchpad-retail.block-unblock-user-new' : 'block-unblock-user-new', 'launchpad-retail.BharatBillPay': 'BharatBillPayNew', 'launchpad-retail.idfc-new-forgot-password': 'idfc-new-forgot-password', 'launchpad-retail.forgot-username': 'forgot-username', 'launchpad-retail.addMoney':'add-money', /* IRCTC file upload*/ 'launchpad-irctc.FileUpload' :'idfc-irctc-file-upload', 'launchpad-irctc-file-status' : 'idfc-irctc-file-status', 'launchpad-goldBond.investments-cert' : 'idfc-goldBond-certificate', /* MOP Jointly by all */ 'launchpad-retail.idfc-initiated-by-me': 'idfc-initiated-by-me', 'launchpad-retail.idfc-transaction-approval': 'idfc-transaction-approval', 'launchpad-retail.idfc-past-approvals': 'idfc-past-approvals', 'launchpad-retail.idfc-rejected-by-me': 'idfc-rejected-by-me', 'launchpad-retail.idfc-txn-all-summary': 'idfc-transaction-all-summary', /* signature upload*/ 'launchpad.signUpload' : 'idfcRet-upload-signatureSP', 'launchpad.signUpload-sp' : 'idfcbbsp-upload-signatureSP', /* positive pay*/ 'launchpad.positivePay' : 'idfc-positive-pay', 'launchpad.bb-positivePay' : 'idfcbb-positive-pay', /*Zerodha*/ 'launchpad-retail.zerodhaInvestment':'idfc-zerodha-demat', 'launchpad-wms.zerodha-holdings': 'zerodha-holdings', 'launchpad-retail.idfc-gift-prepaid-card': 'idfc-gift-prepaid-card', 'launchpad-retail.idfc-contact-us': 'idfc-contact-us', /* Optimus HPE */ 'launchpad-retail.idfc-hpe-dashboard': 'idfc-hpe-dashboard', 'launchpad-retail.idfc-form-15G':'idfc-form-15G', 'launchpad-retail.myapp':'group-services-request', 'launchpad-retail.karma-first' :'idfc-karma-first', //Remittance 'launchpad-retail.remittance': 'remittance', 'launchpad-retail.idfc-nri-pis-settlement-account': 'idfc-nri-pis-settlement-account', //credit card 'launchpad-retail.creditCard-dashboard': 'credit-dashboard', 'launchpad-retail.creditCard-setNewPin': 'credit-new-pin', 'launchpad-retail.creditCard-bill-payment': 'credit-bill-payment', 'launchpad-retail.creditCard-block-unblock-card': 'credit-block-unblock', 'launchpad-retail.creditCard-management': 'creditCard-management', 'launchpad-retail.creditCard-transactions': 'credit-transactions' }; var showWidgetByHotKeyMap = { /* 'a': 'accounts', 't': 'transactions', 'n': 'new-transfer', 'c': 'address-book', 'r': 'review-transfers', 'l': 'places', 'p': 'p2p-transactions', 'e': 'p2p-enrollment', 'f': 'p2p-preferences', 'b': 'e-bill', 'x': 'external-accounts' */ }; var defaultBehaviorEventName = 'launchpad-retail.behavior'; var showWidget = function(container, tag) { container.loadByBehavior(tag, function() { container.showByBehavior(tag); }); }; //wires up the map above, the containe will ask the container to display widgets var assignEvent = function(container, event) { var tag = showWidgetByEventMap[event]; lpCoreBus.subscribe(event, function(params) { // Explicitly forbid behavior from // processing a specific event. if (params && params._noBehavior) { // eslint-disable-line no-underscore-dangle return; } showWidget(container, tag || params.tag); }); }; var initMappings = function(event) { //ignore propagated events if(this !== event.target) { return; } var container = this; var behaviorsInterfaceImplemented = typeof container.loadByBehavior === 'function' && typeof container.showByBehavior === 'function'; //map retail specific events to container specific actions if(behaviorsInterfaceImplemented) { for(var pubsubEvent in showWidgetByEventMap) { if(showWidgetByEventMap.hasOwnProperty(pubsubEvent)) { assignEvent(container, pubsubEvent); } } assignEvent(container, defaultBehaviorEventName); // bind keypress events $(document).on('keypress.retail', function(e) { //Please don't use e.keycode. It is not cross browser. jquery e.which is more reliable. var key = String.fromCharCode(e.which).toLowerCase(); var behaviorTag = showWidgetByHotKeyMap[key]; var targetElementTagName = e.target.tagName.toLowerCase(); var targetElementContenteditable = e.target.getAttribute('contenteditable'); var validTarget = targetElementTagName !== 'input' && targetElementTagName !== 'textarea' && targetElementTagName !== 'select' && !targetElementContenteditable; // matching behavior tag, target is not an input, not in portalmanager if (behaviorTag && validTarget && !lpCoreUtils.parseBoolean(lpPortal.designMode)) { showWidget(container, behaviorTag); } }); } else { console.warn('Attempting to map behaviors to an item which does implement the behaviors interface'); } }; module.exports = { showWidgetByEventMap: showWidgetByEventMap, // showWidgetByHotKeyMap: showWidgetByHotKeyMap, RetailBehaviors: { behaviors: { 'DOMNodeInsertedIntoDocument': initMappings } } }; });